<?php

require_once "Basic.php";

class FormFieldBirthDate extends FormFieldDate {
  
  public function validate($input) {
    $val = parent::validate($input);
    if($val === true) {
      $temp = explode("/", $input);
      $year = intval($temp[2]);
      $currentYear = intval(date("Y"));
      if($year > $currentYear) {
        return "Voc&ecirc; &eacute um viajante do futuro?";
      }
      else if($currentYear - $year > 150) {
        return "Voc&ecirc; nasceu h&aacute; " . ($currentYear - $year) . " anos?";
      }
      return true;
    }
    else {
      return $val;
    }
  }
  
}
